#coding:utf-8
from django import template

register = template.Library()

@register.simple_tag
def split_to_list(value,separator,index = None,start=None,stop = None):
    '''
    
    :param value: 
    :param separator: 
    :param index: 
    :param start: 
    :param stop: 
    :return: 
    '''
    try:
        if start and stop:
            return "_".join(value.split(separator)[start:stop])

        return value.split(separator)[index]

    except Exception,e:
        return "不存在"



@register.filter(name='last_part')
def last_part(value,sep):
    '''
    
    :param value: 
    :param sep: 
    :return: 
    '''
    return value.split(sep)[-1]
